<?php

      define('install',1);
      include('../common.php');

echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="ar" dir="rtl">
<head>

<style type="text/css">
body { background-color: #EBEBEB; margin: 0px 0px 0px 0px;}
</style>

  <title>مرحباً بك في ملف تركيب برنامج  MySmartBB 1.7.0</title>
  <link rel="stylesheet" href="style.css" type="text/css" />
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
</head>

<body>
<div align="center">
  <table border="0" cellspacing="1" class="border" summary="الهيدر" width="100%">
    <tr>
      <td width="100%" colspan="7" style="background: url(theme/header_bg.gif) repeat-x ;height:118px;"><img alt="{$board_title}" border="0" src="theme/logo.gif" height="118" /></td>
    </tr>
    <tr>
      <td class="tcat">معالج تركيب برنامج المنتدى العربي MySmartBB 1.7.0</td>
    </tr>
  </table>

  <br />

  <div align="center">
  <table class="border" summary="المحتويات" border="0" cellpadding="0" cellspacing="1" width="98%">
    <tr>
      <td class="context">

                <br />';

      $info_query = $DB->sql_query("SELECT * FROM MySBB_info WHERE id='1'");
      $info_row   = $DB->sql_fetch_array($info_query);

      if (empty($_GET['step'])) { $_GET['step'] = 2; }


    if ($info_row['MySBB_version'] != "1.0.0" and $info_row['MySBB_version'] != "1.0.0a") {
        $SF->error("يجب ان يكون الاصدار 1.0.0 لكي يتم تحديثه");
    }


    if ($_GET['step'] == 2) {

     $table1 = $DB->sql_query("
     CREATE TABLE `MySBB_usertitle` (
         `id` INT( 9 ) NOT NULL AUTO_INCREMENT ,
         `usertitle` VARCHAR( 200 ) NOT NULL ,
         `posts` INT( 9 ) NOT NULL ,
         PRIMARY KEY ( `id` ))");

     if ($table1) {
      $SF->msg("تم إنشاء MySBB_usertitle");
     }
     if (!$table1) {
      $SF->msg("<font color='#FF0000'>لم يتم انشاء MySBB_usertitle</font>");
     }

     $table2 = $DB->sql_query("
     CREATE TABLE `MySBB_toolbox` (
         `id` INT( 9 ) NOT NULL AUTO_INCREMENT ,
         `name` VARCHAR( 200 ) NOT NULL ,
         `tool_type` INT( 1 ) NOT NULL ,
         PRIMARY KEY ( `id` ))");

     if ($table2) {
      $SF->msg("تم إنشاء MySBB_toolbox");
     }
     if (!$table2) {
      $SF->msg("<font color='#FF0000'>لم يتم انشاء MySBB_toolbox</font>");
     }

     $table3 = $DB->sql_query("
     CREATE TABLE `MySBB_ads` (
         `id` INT( 9 ) NOT NULL AUTO_INCREMENT ,
         `sitename` VARCHAR( 200 ) NOT NULL ,
         `site` VARCHAR( 200 ) NOT NULL ,
         `picture` VARCHAR( 200 ) NOT NULL ,
         `width` INT( 9 ) NOT NULL ,
         `height` INT( 9 ) NOT NULL ,
         `clicks` INT( 9 ) NOT NULL ,
         PRIMARY KEY ( `id` ))");

     if ($table3) {
      $SF->msg("تم إنشاء MySBB_ads");
     }
     if (!$table3) {
      $SF->msg("<font color='#FF0000'>لم يتم انشاء MySBB_ads</font>");
     }

     $table4 = $DB->sql_query("
         CREATE TABLE `MySBB_supermemberlogs` (
         `id` INT( 9 ) NOT NULL AUTO_INCREMENT ,
         `username` VARCHAR( 200 ) NOT NULL ,
         `edit_action` VARCHAR( 255 ) NOT NULL ,
         `subject_title` VARCHAR( 200 ) NOT NULL ,
         `subject_id` INT( 9 ) NOT NULL ,
         `edit_date` VARCHAR( 10 ) NOT NULL ,
     PRIMARY KEY ( `id` ))");

     if ($table4) {
      $SF->msg("تم إنشاء MySBB_supermemberlogs");
     }
     if (!$table4) {
      $SF->msg("<font color='#FF0000'>لم يتم انشاء MySBB_supermemberlogs</font>");
     }
     $SF->html('<br /><div align="center"><input type="submit" onclick="location.href=\'update1.1.php?step=3\'" value="الخطوه التاليه - الحقول الجديده" name="B1" /></div>');
    }

    if ($_GET['step'] == 3) {
     $SF->html('
     <title>MySmartBB 1.0.0 -> MySmartBB 1.1 - الحقول الجديده</title>
     <p align="center">
     # يجب ان تنجح 42 عمليه بداية من الصفر
     ');

     $query = array(
     "ALTER TABLE `MySBB_subject` CHANGE `status` `stick` INT(1) DEFAULT '0' NOT NULL",
     "ALTER TABLE `MySBB_subject` ADD `close` INT( 1 ) NOT NULL AFTER `stick`",
     "ALTER TABLE `MySBB_subject` ADD `delete_topic` INT( 1 ) NOT NULL AFTER `close`",
     "ALTER TABLE `MySBB_group` ADD `vice` INT( 1 ) NOT NULL",
     "ALTER TABLE `MySBB_member` ADD `hide_online` INT( 1 ) NOT NULL",
     "ALTER TABLE `MySBB_online` ADD `hide_browse` INT( 1 ) NOT NULL",
     "ALTER TABLE `MySBB_today` ADD `hide_browse` INT( 1 ) NOT NULL ",
     "ALTER TABLE `MySBB_group` ADD `show_hidden` INT( 1 ) NOT NULL ",
     "ALTER TABLE `MySBB_reply` ADD `action_by` VARCHAR( 200 ) NOT NULL ",
     "ALTER TABLE `MySBB_reply` ADD `delete_topic` INT( 1 ) NOT NULL ",
     "UPDATE `MySBB_group` SET `show_hidden` = '1' WHERE `id` = '1'",
     "ALTER TABLE `MySBB_online` CHANGE `username` `username` VARCHAR( 255 ) NOT NULL",
     "ALTER TABLE `MySBB_online` ADD `username_style` VARCHAR( 255 ) NOT NULL ",
     "ALTER TABLE `MySBB_group` ADD `view_usernamestyle` INT( 1 ) NOT NULL ",
     "ALTER TABLE `MySBB_section` ADD `section_password` VARCHAR( 50 ) NOT NULL ,ADD `show_sig` INT( 1 ) DEFAULT '1' NOT NULL ,ADD `usesmartcode_allow` INT( 1 ) DEFAULT '1' NOT NULL",
     "ALTER TABLE `MySBB_section` ADD `section_picture` VARCHAR( 200 ) NOT NULL",
     "ALTER TABLE `MySBB_section` ADD `sectionpicture_type` INT( 1 ) NOT NULL ",
     "ALTER TABLE `MySBB_section` ADD `linksection` INT( 1 ) NOT NULL ,ADD `linkvisitor` INT( 9 ) NOT NULL ",
     "ALTER TABLE `MySBB_section` ADD `linksite` VARCHAR( 200 ) NOT NULL ",
     "ALTER TABLE `MySBB_section` ADD `subject_order` INT( 1 ) DEFAULT '1'  NOT NULL ",
     "ALTER TABLE `MySBB_group` ADD `usertitle_change` INT( 1 ) NOT NULL ",
     "ALTER TABLE `MySBB_style` ADD `template_path` VARCHAR( 200 ) NOT NULL ",
     "ALTER TABLE `MySBB_section` ADD `use_section_picture` INT( 1 ) NOT NULL AFTER `sectionpicture_type` ",
     "ALTER TABLE `MySBB_online` ADD `user_location` VARCHAR( 200 ) NOT NULL ",
     "ALTER TABLE `MySBB_group` ADD `onlinepage_allow` INT( 1 ) NOT NULL",
     "ALTER TABLE `MySBB_member` ADD `send_allow` INT( 1 ) NOT NULL ",
     "ALTER TABLE `MySBB_online` ADD `subject_show` INT( 1 ) NOT NULL ,ADD `subject_id` INT( 9 ) NOT NULL",
     "ALTER TABLE `MySBB_info` ADD `supermember_logs` INT( 1 ) NOT NULL",
     "ALTER TABLE `MySBB_section` ADD `hide_subject` INT( 1 ) NOT NULL ",
     "ALTER TABLE `MySBB_group` ADD `admincp_section` INT( 1 ) NOT NULL ,ADD `admincp_option` INT( 1 ) NOT NULL ,ADD `admincp_member` INT( 1 ) NOT NULL ,ADD `admincp_membergroup` INT( 1 ) NOT NULL ,ADD `admincp_membertitle` INT( 1 ) NOT NULL ,ADD `admincp_admin` INT( 1 ) NOT NULL ,ADD `admincp_adminstep` INT( 1 ) NOT NULL ,ADD `admincp_subject` INT( 1 ) NOT NULL ,ADD `admincp_database` INT( 1 ) NOT NULL ,ADD `admincp_fixup` INT( 1 ) NOT NULL ,ADD `admincp_ads` INT( 1 ) NOT NULL ,ADD `admincp_template` INT( 1 ) NOT NULL ,ADD `admincp_adminads` INT( 1 ) NOT NULL ,ADD `admincp_attach` INT( 1 ) NOT NULL ,ADD `admincp_page` INT( 1 ) NOT NULL ,ADD `admincp_block` INT( 1 ) NOT NULL ,ADD `admincp_style` INT( 1 ) NOT NULL ,ADD `admincp_toolbox` INT( 1 ) NOT NULL ,ADD `admincp_smile` INT( 1 ) NOT NULL ,ADD `admincp_icon` INT( 1 ) NOT NULL ,ADD `admincp_avater` INT( 1 ) NOT NULL",
     "UPDATE `MySBB_group` SET `admincp_membertitle` = '1',`admincp_admin` = '1',`admincp_adminstep` = '1',`admincp_subject` = '1',`admincp_database` = '1',`admincp_fixup` = '1',`admincp_ads` = '1',`admincp_template` = '1',`admincp_adminads` = '1',`admincp_attach` = '1',`admincp_page` = '1',`admincp_block` = '1',`admincp_style` = '1',`admincp_toolbox` = '1',`admincp_smile` = '1',`admincp_icon` = '1',`admincp_avater` = '1',admincp_membergroup='1',admincp_member='1',admincp_option='1',admincp_section='1',onlinepage_allow='1' WHERE `id` = '1'",
     "ALTER TABLE `MySBB_group` ADD `group_order` INT( 9 ) NOT NULL",
     "INSERT INTO `MySBB_group` VALUES (8, 'مساعد المدير', '" . addslashes('<b><font color="#80000">[username]</font></b>') . "', 'مساعد المدير', 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 2)",
     "UPDATE `MySBB_group` SET `group_order` = '1',username_style='" . addslashes('<b><i><font color="#80000">[username]</i></font></b>') . "' WHERE `id` = '1'",
     "UPDATE `MySBB_group` SET `group_order` = '3',username_style='" . addslashes('<b><font color="#FF0000">[username]</font></b>') . "' WHERE `id` = '2'",
     "UPDATE `MySBB_group` SET `group_order` = '4',username_style='" . addslashes('<font color="#0000FF"><b>[username]</b></font>') . "' WHERE `id` = '3'",
     "UPDATE `MySBB_group` SET `group_order` = '5',username_style='" . addslashes('<font color="#000000">[username]</font>') . "' WHERE `id` = '4'",
     "UPDATE `MySBB_group` SET `group_order` = '6',username_style='" . addslashes('<font color="#008080">[username]</font>') . "' WHERE `id` = '5'",
     "UPDATE `MySBB_group` SET `group_order` = '7',username_style='" . addslashes('<font color="#FF0000">[username]</font>') . "' WHERE `id` = '6'",
     "UPDATE `MySBB_group` SET `group_order` = '2',username_style='" . addslashes('<b><font color="#80000">[username]</font></b>') . "' WHERE `id` = '8'",
     "UPDATE `MySBB_style` SET `template_path` = 'style/template' WHERE `id`='1'",
     "UPDATE `MySBB_group` SET `view_usernamestyle` = '1'",
     "UPDATE `MySBB_group` SET `view_usernamestyle` = '0' WHERE id='7'");

     foreach ($query as $key => $value) {
      $query = $DB->sql_query($value);
      if ($query) {
       $SF->msg("تمت العمليه #" . $key);
      }
     }
     $SF->html('<br /><div align="center"><input type="submit" onclick="location.href=\'update1.1.php?step=4\'" value="الخطوه التاليه - الخطوه الاخيره" name="B1" /></div>');
    }

    if ($_GET['step'] == 4) {
     $update = $DB->sql_query("UPDATE MySBB_info SET MySBB_version='1.1'");
     if ($update) {
      $SF->msg("تم بفضل الله تعالى التحديث إلى الاصدار 1.1");
      $SF->msg("MySmartBB : منتدى العرب");
      $SF->msg("http://www.MySmartBB.com");
      $SF->html('<br /><div align="center"><input type="submit" onclick="location.href=\'update1.1.1.php\'" value="إكمال الترقية للإصدار الموالي " name="B1" /></div>');
     }
    }

echo'<br />

        </td>
  </tr>
  <tr>
    <td class="footer">هذا المنتدى يعمل على برنامج <a href="http://www.mysmartbb.com">MySmartBB</a> | إعداد وبرمجة فريق MySmartBB
    </td>
  </tr>
</table>
</div>
</div>
</body>
</html>';
?>